<?php

use Library\App;
use Library\Request;
use Library\Response;

if (!function_exists("app")){
    /**
     * @return App
     */
    function app(): App
    {
        return App::make();
    }
}

if (!function_exists("app_path")){
    /**
     * 获取app下目录路径
     * @param string|null $path
     * @return string
     */
    function app_path(string $path = null): string
    {
        return LOW_CODE_APP_PATH.($path?"/".ltrim($path,"/"):"");
    }
}

if (!function_exists("config_path")){
    /**
     * 获取app下目录路径
     * @param string|null $path
     * @return string
     */
    function config_path(string $path = null): string
    {
        return LOW_CODE_CONFIG_PATH.($path?"/".ltrim($path,"/"):"");
    }
}

if (!function_exists("public_path")){
    /**
     * 获取public下目录路径
     * @param string|null $path
     * @return string
     */
    function public_path(string $path = null): string
    {
        return LOW_CODE_PUBLIC_PATH.($path?"/".ltrim($path,"/"):"");
    }
}

if (!function_exists("request")){
    /**
     * @return Request
     */
    function request(): Request
    {
        return Request::make();
    }
}

if (!function_exists("response")){
    /**
     * @return Response
     */
    function response(): Response
    {
        return Response::make();
    }
}